from tortoise.models import Model
from tortoise import fields


class BaseModel(Model):
    id = fields.BigIntField(pk=True, index=True)
    class Meta:
        abstract = True

class TimestampMixin:
    """
    时间 Mixin
    """
    created_at = fields.DatetimeField(auto_now_add=True, index=True, description="创建时间")
    updated_at = fields.DatetimeField(auto_now=True, index=True, description="更新时间")

class UserMixin:
    """
    用户 Mixin
    """
    created_by = fields.BigIntField(default=None, description="创建者")
    updated_by = fields.BigIntField(default=None, description="更新者")

class DeletedMixin:
    """
    逻辑删除 Mixin
    """
    deleted = fields.BooleanField(default=False, description="逻辑删除标志")